﻿using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using K9Nano.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Storage;

namespace K9Nano.EFCore
{
    public interface IK9DbContext
    {
        bool FiltersDisabled { get; set; }
        bool SuppressAutoSetTenantId { get; set; }
        bool EventsDisabled { get; set; }
        ISessionContext SessionContext { get; }
        ChangeTracker ChangeTracker { get; }

        DbSet<TEntity> Set<TEntity>() where TEntity : class;
        EntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity : class;
        IQueryable<TEntity> Queryable<TEntity>() where TEntity : class;

        int SaveChanges(bool acceptAllChangesOnSuccess = true);
        Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess = true, CancellationToken cancellation = default);
        IDbContextTransaction BeginTransaction();
    }
}